<?php 
require('config.php');
echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Thrissa's Signature Generator Customiser Builder Creator</title>
		<script type="text/javascript" src="js/custom_stats.js"></script>
		<script type="text/javascript" src="js/prototype.js"></script>
		<script type="text/javascript" src="js/autocomplete.js"></script>
		<script type="text/javascript">
		<!--
			var server;
			var player;
			var region = "US";
			var style;
			var selectedtab = "";
			var http;
			var basedomain = "<? echo BASE_DOMAIN; ?>/";
			var domain = "<? echo BASE_DOMAIN; echo (ENABLE_CORALCDN)?'.nyud.net:8080':''; echo BASE_URLPATH; ?>/";
			
			function Loaded() {
				new Autocomplete('fserver', 'suggestions');
				$('fserver').focus();
				
				http = createRequestObject();
				$('tabpvp').onclick = tabClicked;
				$('tabpve').onclick = tabClicked;
				$('tabreport').onclick = tabClicked;
				$('sigMain').style.display = 'none';
				$('step1').onsubmit = step1Submit;
				// preload tabs
				var tab = new Image();
				tab.src = 'assets/tab.gif';
				var tabon = new Image();
				tabon.src = 'assets/tabon.gif';
			}
			
			function step1Submit() {
				player = $('fcharacter').value;
				server = $('fserver').value;
				region = (($('fregionEU').checked == true) ? $('fregionEU').value : $('fregionUS').value);
				if (server == '') {
					$('fserver').focus();
					return false;
				} else if (player == '') {
					$('fcharacter').focus();
					return false;
				}
				$('sigMain').style.display = 'block';
				selectTab('pve');
				// create the image links
				updateSigs();
				return false; // stop form submission
			}
			
			/* updates the div with all the different sig styles and links */
			function updateSigs() {
				var sigs = $('sigDisplay');
				sigs.innerHTML = "";
				if (selectedtab == 'report') {
					sigs.innerHTML += "<p>Please leave any comments here you wish, I'm especially interested to hear of the following:<ul><li>Incorrect stats (please ensure the <a href='http://armory.worldofwarcraft.com/'>Armory</a> has the correct ones!)</li><li>Images missing</li><li>Misspellings</li></ul> and any suggestions you may have for improvements to the sig generator.<br /><br />I'll read every comment posted, but I can't promise to reply, or implement all suggestions :).</p>";
					sigs.innerHTML += "<p><b>If you are posting a specific bug, please let me know a character and server that displays the problem.</b></p><p><br />Otherwise, thanks for your comments and bugs!,<br /><a href='mailto:thrissa@gmail.com'>Thrissa</a> &lt;<a href='http://www.eminencewow.net/'>Eminence</a>&gt; of Blackrock";
					sigs.innerHTML += "<form id='bugForm' onsubmit='return submitBugReport()' action='#'><textarea id='bugReport'></textarea><br /><input type='submit' value='Send Comment' id='bugSubmit' /></form><div id='submitStatus'></div>";
				} else if (selectedtab == 'pve') {
					for(i = 1; i <= 4; i++) {
						sigs.innerHTML += "<h3>Style "+i+"</h3> - <span class='statmodlink' onclick='statmod("+i+")'>[modify stats]</span><br /><img src=\""+basedomain+region+"/"+selectedtab+"/"+server+"/"+player+"/sig"+i+".jpg\" /><br /><br />";
						sigs.innerHTML += "<div class=\"clabel\">Forum Sig:</div><input type=\"text\" size=\"100\" value=\"[img]"+domain+region+"/"+selectedtab+"/"+server+"/"+player+"/sig"+i+".jpg[/img]\" /><br />";
						sigs.innerHTML += "<div class=\"clabel\">HTML Image:</div><input type=\"text\" size=\"100\" value=\"&lt;img src=&quot;"+domain+region+"/"+selectedtab+"/"+server+"/"+player+"/sig"+i+".jpg&quot; /&gt;\" /><br />";
						sigs.innerHTML += "<div class=\"clabel\">Image Link:</div><input type=\"text\" size=\"100\" value=\""+domain+region+"/"+selectedtab+"/"+server+"/"+player+"/sig"+i+".jpg\" /><hr />";
					}
				} else { // pvp
					for(i = 1; i <= 3; i++) {
						sigs.innerHTML += "<h3>Style "+i+"</h3><br /><img src=\""+basedomain+region+"/"+selectedtab+"/"+server+"/"+player+"/sig"+i+".jpg\" /><br /><br />";
						sigs.innerHTML += "<div class=\"clabel\">Forum Sig:</div><input type=\"text\" size=\"100\" value=\"[img]"+domain+region+"/"+selectedtab+"/"+server+"/"+player+"/sig"+i+".jpg[/img]\" /><br />";
						sigs.innerHTML += "<div class=\"clabel\">HTML Image:</div><input type=\"text\" size=\"100\" value=\"&lt;img src=&quot;"+domain+region+"/"+selectedtab+"/"+server+"/"+player+"/sig"+i+".jpg&quot; /&gt;\" /><br />";
						sigs.innerHTML += "<div class=\"clabel\">Image Link:</div><input type=\"text\" size=\"100\" value=\""+domain+region+"/"+selectedtab+"/"+server+"/"+player+"/sig"+i+".jpg\" /><hr />";
					}
				}
			}
			
			/* time to modify the stats of the current sig */
			function statmod(selected) {
				style = selected;
				var sigs = $('sigDisplay');
				sigs.innerHTML = "<p>Welcome to the stats selection! Pick your 5 stats and hit update!</p>";
				// add in the selector bits
				for (i = 0; i < 5; i++) { // 5 stats for a sig
					sigs.innerHTML += "<select id='statdropdown"+i+"'></select><br />";
					var statdropdown = $('statdropdown'+i);
					for (j = 0; j < custom_stats.length; j++) {
						statdropdown.options[j] = new Option(custom_stats[j][1], custom_stats[j][0]);
					}
				}
				sigs.innerHTML += "<input type='button' onclick='statpreview()' value='OMGupdate' id='statbutton' /><br /><hr />";
				sigs.innerHTML += "<div id='statpreview'></div>";
				statpreview();
			}
			
			/* rewrites the html inside the preview based on current selections */
			function statpreview() {
				// grab the selections, and create the hash
				var hash = '';
				for (i = 0; i < 5; i++) {
					var statdropdown = $('statdropdown'+i);
					hash += statdropdown.value;
				}
				var statpreview = $('statpreview');
				statpreview.innerHTML = '';
				statpreview.innerHTML += "<h3>Style "+style+"</h3><br /><img src=\""+basedomain+region+"/"+selectedtab+"/"+server+"/"+player+"/sig"+style+"stats"+hash+".jpg\" /><br /><br />";
				statpreview.innerHTML += "<div class=\"clabel\">Forum Sig:</div><input type=\"text\" size=\"100\" value=\"[img]"+domain+region+"/"+selectedtab+"/"+server+"/"+player+"/sig"+style+"stats"+hash+".jpg[/img]\" /><br />";
				statpreview.innerHTML += "<div class=\"clabel\">HTML Image:</div><input type=\"text\" size=\"100\" value=\"&lt;img src=&quot;"+domain+region+"/"+selectedtab+"/"+server+"/"+player+"/sig"+style+"stats"+hash+".jpg&quot; /&gt;\" /><br />";
				statpreview.innerHTML += "<div class=\"clabel\">Image Link:</div><input type=\"text\" size=\"100\" value=\""+domain+region+"/"+selectedtab+"/"+server+"/"+player+"/sig"+style+"stats"+hash+".jpg\" /><hr />";
				return false;
			}
			
			/* grab the data from the form, send it off via ajax to the mailer (yes, folk reading this, it just emails it, plz no spam :< ) */
			function submitBugReport() {
				var bugReport = $('bugReport');
				var submitStatus = $('submitStatus');
				submitStatus.innerHTML = 'Sending comment...';
				var params = "msg="+bugReport.value;
				http.open('POST', 'bugSubmit.php', true);
				
				//Send the proper header information along with the request
				http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				http.setRequestHeader("Content-length", params.length);
				http.setRequestHeader("Connection", "close");
				http.onreadystatechange = submitBugReportResponse;
				
				http.send(params);
				return false;
			}
			
			/* ajax callback */
			function submitBugReportResponse() {
				if(http.readyState == 4 && http.status == 200) {
					var sigs = $('sigDisplay');
					sigs.innerHTML = "<div id='submitStatus'>"+http.responseText+"</div>";
				}
			}
			
			function createRequestObject() {
				var ro;
			  var browser = navigator.appName;
				if(browser == "Microsoft Internet Explorer"){
					ro = new ActiveXObject("Microsoft.XMLHTTP");
				}else{
					ro = new XMLHttpRequest();
				}
				return ro;
			}

			/* tab clicked, update sigs list */
			function tabClicked() {
				switch (this.id) {
					case 'tabpvp':
						selectTab('pvp');
						break;
					case 'tabreport':
						selectTab('report');
						break;
					case 'tabpve':
					default:
						selectTab('pve');
						break;
				}
				updateSigs();
			}
			
			/* select the tab, change styles and update the display  */
			function selectTab(tabname) {
				selectedtab = tabname;
				$('tabpve').style.background = "url('assets/tab.gif')";
				$('tabpvp').style.background = "url('assets/tab.gif')";
				$('tabreport').style.background = "url('assets/tab.gif')";
				$('tab'+tabname).style.background = "url('assets/tabon.gif')";
			}
		//-->
		</script>
		<link href="siggen.css" rel="stylesheet" type="text/css" />
	</head>
	<body onload="Loaded()">
		<h1>Thrissa's Signature Generator Customiser Builder Creator</h1>
		<p class="latest">
			Version 0.6 (26th March): Added Europe support, Autocomplete servername and Coral CDN usage along with many backend changes.<br />
			<a href="#" onclick="document.getElementById('pastchangeslink').style.display='none';document.getElementById('pastchanges').style.display='block';document.getElementById('pastchangeslinkhide').style.display='inline';return false;" id="pastchangeslink">[Past Changes]</a>
			<a href="#" onclick="document.getElementById('pastchangeslink').style.display='inline';document.getElementById('pastchanges').style.display='none';document.getElementById('pastchangeslinkhide').style.display='none';return false;" id="pastchangeslinkhide" style="display:none">[Hide Past Changes]</a>
			<div id="pastchanges" style="display: none">
				Version 0.5 (8th March): RAWR, custom stats are here! Click the red [modify stats] link in the PvE tab to see more. Also the comment/bugs tab is now active and awaiting your comments!<br />
				Version 0.4 (8th March): Underlying code base rewritten to support custom stats on PvE sigs, many performance and caching improvements. Front end customiser coming tomorrow :)<br />
				Version 0.3 (6th March): Realms with numbers are now supported. Many additional styles and options coming soon...<br />
				Version 0.2 (5th March): Added support for realms with spaces and quotes.<br />
				Version 0.1 (4th March): Currently for US realms only, untested for realms with spaces and quotes. Also does not support names outside normal [A-Za-z]+ ranges.
			</div>
		</p>
		<div id="notice">26th March 2007<br />
			<p>
					New server! New features! Same sigs!. These ones you CAN put into your sigs once more!<br />
					If you're looking for more designs, do a mockup and send it to me! (imageshack links preferred).
			</p>
			<p>
					Also added Europe support, and now using the <a href="http://coralcdn.org/">Coral Content Distribution Network</a>.
			</p>
			<p>
					<b>Update:</b> Added a <a href="basicstats.php">basic stats page</a>, if you're interested in numbers. Maybe a pretty graph in the future :)<br />
				<b>Update #2:</b> Added a <a href="arena.php">World Top-50 5's Leaderboard</a> for ye arena whores.
			</p>
			<p>
					<a href="http://code.google.com/p/wow-armory-siggen/">Source is still available</a> for anyone to host their own servers! (php5 now supported!)
			</p>
			<p>
					<a href="mailto:thrissa@gmail.com">Thrissa</a> &lt;<a href="http://www.eminencewow.net/">Eminence</a>&gt; of Blackrock
			</p>
			<hr />
			<a href="#" onclick="document.getElementById('pastnoticeslink').style.display='none';document.getElementById('pastnotices').style.display='block';return false;" id="pastnoticeslink">[Past Notices]</a>
			<div id="pastnotices" style="display: none">
				<a href="#" onclick="document.getElementById('pastnotices').style.display='none';document.getElementById('pastnoticeslink').style.display='inline';return false;">[Hide Past Notices]</a><br />
				20th March 2007
				<p>
					I've been busy with job applications, havn't had time to put this up. The full hosting I was going to use hasn't come through, and since i'm almost too busy with other things to work on this enough, i'm going to release it to the community. This means you can host your own sig generators, you can create your own themes, you can get your own stats, you can support europe yourself :).
				</p>
				<p>
					Source code is up online at <b><a href="http://code.google.com/p/wow-armory-siggen/">http://code.google.com/p/wow-armory-siggen/</a></b>!, Please, if you're working on this, and you add something cool, or you support europe, I'd appreciate you taking the time to commit your changes, or make a new branch of the project for everyone else to use, too.
				</p>
				<p>
					oh, there's one <b>big</b> problem with the source code at the moment. The character parser only works on php4 (oops, call-time pass-by-reference deprecated in php5). I havn't looked any more into this, It may be a small change, it may be a large change. If anyone has the time, please let me know, or submit a fix to subversion :)
				</p>
				<p>
					Thank you for all the hosting offers, and your comments of "this is awesome!", now make it better! :)
				</p>
				<hr />
				12th March 2007
				<p>
					Here's a cool graph, showing the hits(images sent out) over the few days the siggen was active on jebus.geek.nz. After the steep drop on the graph, 404 errors plagued the server for many hours to come. My log files are huge!<br />
					<img src="hourlyhitsgraph.jpg" /><br />
					<b>Dreamhost says: "Please do not do this again for the sake of stability of our shared hosting servers."</b>
				</p>
				<p>
					<b>In summary:</b><br />
					Total Hits: 1,249,509 (not incl. 404's)<br />
					Total Bandwidth: 10.66 GB<br />
					Unique Hits: 16,560<br />
					Disk Cache: 840 MB<br />
					File Not Found Errors: 588,099
				</p>
			</div>
		</div>
		<div id="serverchar"><h2>Server and Character name</h2>
			<form id="step1" name="step1" action="#" method="GET">
				<div class="slabel">Region:</div>
				<div class="sinput"><input type="radio" id='fregionUS' name='fregion' value='us' checked='checked' /><label for="fregionUS">US</label> <input type="radio" id='fregionEU' name="fregion" value="eu" /><label for="fregionEU">Europe</label></div>
				
				<div class="slabel">Server:</div>
				<div class="sinput"><input type='text' id='fserver' name='server' value='' /></div>
				<div id="suggestions"></div>
				
				<div class="slabel" style="clear: both">Character:</div>
				<div class="sinput"><input type='text' id='fcharacter' name='character' value='' /></div>
			
				<div class="slabel">&nbsp;</div>
				<input type="submit" value="Sig Me" />
			</form>
		</div>
		<div id="sigMain">
			<b>Important:</b> Please copy+paste the link on the page, and <b>not</b> copy image location! This is so the <a href="http://www.coralcdn.org/">coral cache</a> can be used to keep my server happy!
			<div id="tabs">
				<div id="tabpve" class="tab">PvE Sigs</div>
				<div id="tabpvp" class="tab">PvP Sigs</div>
				<div id="tabreport" class="tab">Comment/Bugs</div>
			</div>
			<div id="sigDisplay">
			</div>
		</div>
	</body>
</html>
